﻿using System;
using UnityEngine;

namespace Framework
{
    public class EventTargetMonoBehaviour : MonoBehaviour, IEventTarget
    {
        private EventTarget _eventTarget;
        
        public virtual void Awake()
        {
            _eventTarget = new EventTarget();
        }

        public virtual void OnDestroy()
        {
            _eventTarget.Dispose();
        }

        public void AddListener(int type, Action<ETEvent> onEvent)
        {
            _eventTarget.AddListener(type, onEvent);
        }

        public void RemoveListener(int type, Action<ETEvent> onEvent)
        {
            _eventTarget.RemoveListener(type, onEvent);
        }

        public void Emit(int type, params object[] args)
        {
            _eventTarget.Emit(type, args);
        }
    }
}